
const path = require('path');
const webpack=require('webpack');
const htmlWebpackPlugin=require('html-webpack-plugin');

module.exports={
    entry:path.join(__dirname,'./src/main.js'),
    output:{
        path:path.join(__dirname,"./dist"),
        filename:'bundle.js'
    },
    plugins:[  //配置插件的节点
        //创建一个可以在内存中自动自重html文件的插件工具
        new htmlWebpackPlugin({
            template:path.join(__dirname,'./src/index.html'),   //指定模板文件
            filename:'index.html'
        })
    ],
    module:{
        rules:[
            {test:/\.css$/,use:['style-loader','css-loader']},
            {test:/\.less$/,use:['style-loader','css-loader','less-loader']},
            {test:/\.scss$/,use:['style-loader','css-loader','sass-loader']},
            {test:/\.(jpg|png|bmp|gif|jpeg)$/,use:'url-loader?name=[hash:8].[ext]'},
            {test:/\.(ttf|woff|woff2|svg|eot)$/,use:'url-loader'},
            {test:/\.js$/,use:'babel-loader',exclude:/node_modules/},
            {test:/\.vue$/,use:'vue-loader'}
        ]
    }
}